﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WAD.WEB.AppCode;
using WAD.Model;
using WAD.DAL;
using System.Data;
using WAD.WEB.AppCode.Pay.WxPay;

namespace WAD.WEB.Client.Ajax
{
    /// <summary>
    /// 获取微信预支付订单号
    /// </summary>
    public class WxPayInfo : AjaxBase
    {
        public override void AjaxMethodDispatch(String identity)
        {
            switch (identity)
            {
                case "get": this.Get(); break;
            }
        }
        /// <summary>
        /// 获取微信预支付订单号
        /// </summary>
        [QD.Web.Ajax.AjaxMethod]
        public void Get()
        {
            String subject = Parse.String("subject");//标题
            String body = Parse.String("body");//详情
            String notifyUrl = Parse.String("notifyUrl");//回调地址
            String outTradeNo = Parse.String("outTradeNo");//订单号
            int money = Parse.Int("money", 0);//支付金额(单位:分)

            if (String.IsNullOrEmpty(subject) || String.IsNullOrEmpty(body) || String.IsNullOrEmpty(notifyUrl)
                || String.IsNullOrEmpty(outTradeNo) || money < 1)
            {
                ParamError();
            }
            Dictionary<String, object> map = MakeOrder.MekePrepayId(subject, body, notifyUrl, outTradeNo, money);

            if (map == null)
            {
                JsonResult(-1,"生成支付订单异常,请联系管理员查看错误日志!");
            }
            else
            {
                Success(map);
            }
        }
    }
}